-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mapping to avoid infinite loop #15
Conversation
1. Add map object with self link as key and array of linkName as value 2. Skip fetching data if map[self] contain linkName
@@ -67,6 +67,8 @@ angular.module("spring-data-rest").provider("SpringDataRestAdapter", function () | |||
}, | |||
|
|||
$get: ["$injector", function ($injector) { | |||
// map contain self link as key and a list of linkNames which were already fetched |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would write something like:
/**
* Link map which contains the 'self' link as key and the list of already fetched link names as value. This is used to
* check that every link on each entity is only fetched once to avoid an infinite recursive loop.
*/
var linkMap = {}
Then it is more clear for that the map is used. And I would also rename the map
variable to linkMap
.
You should also reinitialize the map at this line: https://github.com/guylabs/angular-spring-data-rest/pull/15/files#diff-f3122e396df944c9b7692dbac86ded5bR328 as if not, then all entity links are only fetched once as the map is not cleared for each processing. And could you also add some tests to the test suite which tests the following use cases:
Please have a look at the Thanks a lot for the pull request! Regards, Guy |
Hi @guylabs Could you tell me what you mean
Thanks |
1. Update naming convention 2. Use config attribute to get self href
Hi Romy, you mean line https://github.com/rkusuma/angular-spring-data-rest/blob/master/src/angular-spring-data-rest-provider.js#L63 right? Well the thing is that the Do you know what I mean? Thanks and regards, Guy |
Hi @guylabs You can see in this line https://github.com/rkusuma/angular-spring-data-rest/blob/master/src/angular-spring-data-rest-provider.js#L370 Is that what you mean?
Thanks |
1. Create mock data 2. Add test cases to test infinite loop
@guylabs |
Hi Romy, sorry for not seeing the initialization of the map. So there everything is ok :). And the tests are also good. Nice work and thanks a lot for you contribution. I will now merge it to the master and then you are able to use it right away in your project. Thanks and regards, Guy |
Add mapping to avoid infinite loop
Thanks Guy.. |
I can do a 0.4.3 release this evening if you want to. In the mean time you can have a look at this post and see how to use the master in bower: http://guylabs.ch/2015/05/08/get-latest-master-changes-of-a-bower-dependency/ |
Okay.. I'll wait |
Hi Romy, I just released the And thanks again for your contribution! Regards, Guy |
Hi @guylabs,
Based on what you said in #12
I just creating your solution. Please kindly check if it right or not.